package com.gin.no_gay_alliance.database.entity;

import androidx.room.Entity;
import androidx.room.Index;
import androidx.room.PrimaryKey;

import com.gin.no_gay_alliance.viewmodel.ReplyItem;

/**
 * 举报记录
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2024/1/23 10:28
 **/
@Entity(indices = {
        @Index(value = {"timestamp"})
})
public class ReportingRecord {
    @PrimaryKey(autoGenerate = true)
    public int id;
    /**
     * 时间戳
     */
    public long timestamp;
    /**
     * 被举报人ID（非匿名）
     */
    public Long userId;
    /**
     * 被举报人用户名（非匿名）
     */
    public String username;
    /**
     * 主题id
     */
    public long topicId;
    /**
     * 标题
     */
    public String title;
    /**
     * 回复ID
     */
    public long replyId;
    /**
     * 理由
     */
    public String reason;
    /**
     * 被举报的发言内容
     */
    public String content;

    public ReportingRecord() {
    }

    public ReportingRecord(ReplyItem item, String reason) {
        this.timestamp = System.currentTimeMillis() / 1000;
        // 非匿名时才复制用户名 用户id
        if (!item.anonymous) {
            this.userId = item.authorUid;
            this.username = item.username;
        }
        this.topicId = item.topicId;
        this.title = item.title;
        this.replyId = item.replyId;
        this.reason = reason;
        this.content = item.content;
    }

}
